package yaml;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ho.yaml.Yaml;

public class YamlReader {

    String configFile = "mitachList.yml";
    ArrayList<MitachElement> mitachConfig = new ArrayList<MitachElement>();

    public YamlReader() {
    }

    public ArrayList<MitachElement> readConfig() throws FileNotFoundException {
        return Yaml.loadType(new File(configFile), ArrayList.class);
    }

    public void setConfigFile(String configFile) {
        this.configFile = configFile;
    }

//    public static void main(String[] args) {
//        new YamlReader().writeConfig();
//    }
    
    private void writeConfig() {
        MitachElement el1 = new MitachElement("type1", "srcNeiroReports\\Res_2_20 50 10.txt.eg", 
                0.07, 50, 10);
//        MitachElement el2 = new MitachElement("type2", "2.eg", 10.098, 50, 8);
        ArrayList<MitachElement> mitach = new ArrayList<MitachElement>();
        mitach.add(el1);
//        mitach.add(el2);
        try {
            Yaml.dump(mitach, new File(configFile));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(YamlReader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
